#! /bin/bash

tredDir="$1"

if [ "${tredDir}" = "" ]; then
    echo "Usage: the first and only argument should be the path to the web2py application folder."
    exit 0
fi

length="${#tredDir}"

end=${tredDir:${length}-1:1}

if [ "$end" != "/" ]; then
    tredDir="${tredDir}/"
fi

wget --quiet http://www.web2py.com/examples/static/web2py_src.zip

unzip web2py_src.zip > /dev/null

mkdir web2py/applications/init

cp -R ${tredDir} web2py/applications/init/

zip -r tred-web2pySource web2py > /dev/null

rm -rf web2py

rm web2py_src.zip
    
exit 0
